/*=====================================================================
  This file is part of a Microsoft SQL Server Shared Source Application.
  Copyright (C) Microsoft Corporation.  All rights reserved.
 
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
======================================================= */

using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.SqlServer.BI.ASLoadSim
{
    /// <summary>
    /// Update column "TransactionText" in table [dbo].[WebLoadTestTransactionContent]
    /// If that column is NULL
    /// The column stores the query text.
    /// </summary>
    public class TransText
    {
        public static void Insert(string server, string db, string transName, string transText)
        {
            using (SqlConnection connection = new SqlConnection(
                @"Data Source=" + server + ";Initial Catalog=" + db + ";Integrated Security=SSPI;"))
            {
                SqlCommand command = new SqlCommand();
                command.Connection = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = @"InsertTrans";
                SqlParameter param1 = new SqlParameter("TransactionName", transName);
                SqlParameter param2 = new SqlParameter("TransactionText", transText);
                command.Parameters.Add(param1);
                command.Parameters.Add(param2);

                command.Connection.Open();
                command.ExecuteNonQuery();
            }
        }
    }
}
